package com.qnaboard.validator;

import org.springframework.validation.Errors;
import org.springframework.validation.ValidationUtils;
import org.springframework.validation.Validator;

import com.qnaboard.domain.QnaBoardCommand;

public class QnaBoardvalidator implements Validator {

	@Override
	public boolean supports(Class<?> clazz) {
		return QnaBoardCommand.class.isAssignableFrom(clazz);
	}

	@Override
	public void validate(Object target, Errors errors) {
		ValidationUtils.rejectIfEmptyOrWhitespace(errors, "password", "required");
		ValidationUtils.rejectIfEmptyOrWhitespace(errors, "writer_name", "required");
		ValidationUtils.rejectIfEmptyOrWhitespace(errors, "num", "required");
		ValidationUtils.rejectIfEmptyOrWhitespace(errors, "title", "required");
		ValidationUtils.rejectIfEmptyOrWhitespace(errors, "content", "required");
		ValidationUtils.rejectIfEmptyOrWhitespace(errors, "write_type", "required");
	}

}
